package com.example.result.explore

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material3.Button
import androidx.compose.material3.ElevatedButton
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.LargeFloatingActionButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.SmallFloatingActionButton
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.dp

@Composable
fun ButtonShow() {
    var isToogle by remember {
        mutableStateOf(false)
    }

    fun onClick() {
        isToogle = !isToogle
    }
    Column {
        var sfHeight by remember {
            mutableStateOf(0)
        }
        Surface(
            color = MaterialTheme.colorScheme.onSurfaceVariant,
            modifier = Modifier.onSizeChanged {
                sfHeight = it.height
            }) {
            var btHeight by remember {
                mutableStateOf(0)
            }
            Button(onClick = { onClick() }, modifier = Modifier
                .padding(0.dp)
                .onSizeChanged {
                    btHeight = it.height
                }) {
                Text("sf:$sfHeight bt:$btHeight")
            }
        }
        HorizontalDivider()
        Button(onClick = { onClick() }) {
            Text("Button")
        }
        FilledTonalButton(onClick = { onClick() }) {
            Text("FilledTonalButton")
        }
        ElevatedButton(onClick = { onClick() }) {
            Text("ElevatedButton")
        }
        OutlinedButton(onClick = { onClick() }) {
            Text("OutlinedButton")
        }
        TextButton(onClick = { onClick() }) {
            Text("TextButton")
        }
        FloatingActionButton(
            onClick = { onClick() },
        ) {
            Icon(Icons.Filled.Add, "FloatingActionButton")
        }
        SmallFloatingActionButton(
            onClick = { onClick() },
        ) {
            Icon(Icons.Filled.Add, "SmallFloatingActionButton")
        }
        LargeFloatingActionButton(
            onClick = { onClick() },
            shape = CircleShape,
        ) {
            Icon(Icons.Filled.Add, "LargeFloatingActionButton")
        }
        ExtendedFloatingActionButton(
            onClick = { onClick() },
            icon = { Icon(if(isToogle) Icons.Filled.Edit else Icons.Filled.CheckCircle, "Extended floating action button.") },
            text = { Text(text = "ExtendedFloatingActionButton") },
        )
    }
}
